package 设计模式第一章;


class Car {
    private Engine engine;

    public Car(Engine engine) { //构造注入
        this.engine = engine;
    }

    public void setEngine(Engine engine) { //set注入
        this.engine = engine;
    }
}
class Engine {
    public void startUp() {
        System.out.println("发动机启动启动..........");
    }
}
public class 聚合关系 { //相互独立的
    public static void main(String[] args) {
        Engine engine = new Engine();
        //Car car = new Car(engine);
        engine.startUp();
    }
}

